package com.ns.rmi.server;

import java.rmi.RemoteException;
import java.util.Properties;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;

import com.ns.rmi.impl.HelloImpl;

public class HelloServer {

	public static void main(String[] args) {
		try {
			System.out.println("######################################");
			System.out.println("Server is being initialized.....");
			HelloImpl obj = new HelloImpl();
			Properties prop = new Properties();
			prop.put("java.naming.factory.initial", "com.sun.jndi.cosnaming.CNCtxFactory");
			prop.put("java.naming.provider.url", "corbaloc:iiop:localhost:20901/NameService");
			Context ctx = new InitialContext(prop);
			ctx.rebind("hello",obj);
			System.out.println("Server Ready....");
			System.out.println("######################################");
		} catch (RemoteException e) {
			e.printStackTrace();
		} catch (NamingException e) {
			e.printStackTrace();
		}


	}

}
